using UnityEngine;

public class FitGridInPanel : MonoBehaviour
{
	public UIPanel panel;

	public bool doCentre;

	private UIGrid _myGrid;

	private bool started;

	private Vector3 initPosition;

	private UIGrid myGrid
	{
		get
		{
			if (_myGrid == null)
			{
				_myGrid = GetComponent<UIGrid>();
			}
			return _myGrid;
		}
	}

	private void OnEnable()
	{
		if (!started)
		{
			DoStart();
		}
		FitInPanel();
	}

	private void DoStart()
	{
		initPosition = base.transform.localPosition;
		started = true;
	}

	private void FitInPanel()
	{
		if (doCentre)
		{
			Vector3 localPosition = initPosition;
			localPosition.x -= panel.width / 4f;
			base.transform.localPosition = localPosition;
		}
	}
}
